package com.info.zhiduoduo.pay.controller;

import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.validator.IntIn;
import com.info.zhiduoduo.pay.formbean.transferpay.TransferAgentPayFormBean;
import com.info.zhiduoduo.pay.formbean.transferpay.TransferQueryAgentPayFormBean;
import com.info.zhiduoduo.pay.service.TransferPayService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import io.swagger.annotations.ApiOperation;

@RequestMapping("/transferpay")
@RestController
public class TransferPayController {

	@Autowired
	TransferPayService transferPayService;

	@ApiOperation("传化代付")
	@PostMapping("/agentPay")
	public SmartResult agentPay(@Valid @RequestBody TransferAgentPayFormBean formBean) {
		return transferPayService.agentPay(formBean);
	}

	@ApiOperation("传化代付查询结果")
	@PostMapping("/queryAgentPay")
	public SmartResult queryAgentPay(@Valid @RequestBody TransferQueryAgentPayFormBean formBean) {
		return transferPayService.queryAgentPay(formBean);
	}

	@ApiOperation("传化武圣账户余额查询")
	@GetMapping("/queryMerchantBalance")
	public SmartResult queryMerchantBalance(@IntIn(value = {4, 5}, message = "商户号不正确")@RequestParam int paymentMerchant) {
		return transferPayService.queryBalance(paymentMerchant);
	}
}
